package cn.kgc.service.feign;

import cn.kgc.common.vo.Result;
import cn.kgc.emp.entity.Emp;
import cn.kgc.service.hystrix.EmpServiceHystrix;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "HELLO-PROVIDER",fallback = EmpServiceHystrix.class)
//@RequestMapping("/emp")   //使用了断路器的情况下，不要在此处使用该注解
public interface EmpServiceFeign {

    @GetMapping("/emp/list")
    public Result<List<Emp>> getEmpList();

    @GetMapping("/emp/{id}")
    public Result<Emp> getEmpById(@PathVariable("id") Integer id);

    @DeleteMapping("/emp/{id}")
    public Result<Emp> deleteEmpById(@PathVariable("id") Integer id);

    @PostMapping("/emp")
    public Result<Emp> addEmp(@RequestBody Emp emp);

    @PutMapping("/emp")
    public Result<Emp> updateEmp(@RequestBody Emp emp);
}
